<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        var arr = [/靠/ig,/tmd/ig,/nm/ig]
        function btnClick(){
            var otxt1 = document.getElementById("txt1")
            var xtxt2 = document.getElementById("txt2")
            var otxtvalue=otxt1.value
            for(var i = 0;i<arr.length;i++){
                otxtvalue=otxtvalue.replace(arr[i],"*")
            }
            xtxt2.innerHTML=otxtvalue
            otxtvalue.value=""
        }

        
    </script>
</head>
<body>
    <textarea id = "txt1" cols="30" rows="10"></textarea>
    <button onclick="btnClick()">发布</button>
    <div id = "txt2"></div>
</body>
</html>